package com.chance.cc.crawler.development.command.trigger.domain.weixin;

import com.chance.cc.crawler.core.CrawlerJob;
import com.chance.cc.crawler.core.downloader.HttpPage;
import com.chance.cc.crawler.development.command.job.domain.weibo.api.realtime.WeiboKeywordsRealtimeCrawlerSchedulerJob;
import com.chance.cc.crawler.development.command.job.domain.weibo.api.trace.WeiboUIDTraceCrawlerSchedulerJob;
import com.chance.cc.crawler.development.command.job.domain.weixin.WeixinCommonScript;
import com.chance.cc.crawler.development.command.job.domain.weixin.api.simple.WXApiSimpleKeywordsCrawlerSchedulerJob;
import com.chance.cc.crawler.development.command.job.domain.weixin.api.simple.WXApiSimpleUIDCrawlerSchedulerJob;
import com.chance.cc.crawler.development.command.job.domain.weixin.api.trace.WeixinKeywordsTraceCrawlerSchedulerJob;
import com.chance.cc.crawler.development.command.job.domain.weixin.api.trace.WeixinUIDTraceCrawlerSchedulerJob;
import com.chance.cc.crawler.development.command.trigger.CommonCrawlerTestSchedulerTrigger;
import com.chance.cc.crawler.meta.core.bean.CrawlerMetaConstant;
import org.junit.Test;

/**
 * @author lt
 * @version 1.0
 * @date 2021-03-19 10:40:51
 * @email okprog@sina.com
 */
public class WeixinAPICrawlerTrigger extends CommonCrawlerTestSchedulerTrigger {

    public static void main(String[] args) {

//        publishWeixinSearchKWTraceCrawlerScheduleTriggerInfo();
//
//        publishWeixinUIDKWTraceCrawlerScheduleTriggerInfo();

        publishWeiXinSimpleTraceCrawlerScheduleTriggerInfo(WXApiSimpleKeywordsCrawlerSchedulerJob.crawlerJobScheduler());
        publishWeiXinSimpleTraceCrawlerScheduleTriggerInfo(WXApiSimpleUIDCrawlerSchedulerJob.crawlerJobScheduler());

    }


    /**
     * 发布微信API关键词采集回溯任务trigger info
     */
    public static void publishWeixinSearchKWTraceCrawlerScheduleTriggerInfo(){
        CrawlerJob crawlerJob = WeixinKeywordsTraceCrawlerSchedulerJob.crawlerJobScheduler();

        metaServiceCommand_15.addOrUpdateScheduleCrawlerTrigger(
                crawlerJob.generateCrawlerKey(),
                crawlerJob.generateCrawlerTriggerKey(),
                WeixinKeywordsTraceCrawlerSchedulerJob.domain,
                CrawlerMetaConstant.ScheduleJobTrigger_Cron,
                "0 0 14 * * ?",
                "微信API关键词回溯前一天正文，四天前互动量采集任务执行，每天下午14:00执行一次"
        );
    }

    /**
     * 发布微信API-UID关键词采集回溯任务trigger info
     */
    public static void publishWeixinUIDKWTraceCrawlerScheduleTriggerInfo(){
        CrawlerJob crawlerJob = WeixinUIDTraceCrawlerSchedulerJob.crawlerJobScheduler();

        metaServiceCommand_15.addOrUpdateScheduleCrawlerTrigger(
                crawlerJob.generateCrawlerKey(),
                crawlerJob.generateCrawlerTriggerKey(),
                WeixinUIDTraceCrawlerSchedulerJob.domain,
                CrawlerMetaConstant.ScheduleJobTrigger_Cron,
                "0 0 14 * * ?",
                "微信API-UID关键词回溯作者前一天发文采集任务执行，每天下午14:00执行一次"
        );
    }

    /*补采*/
    public static void publishWeiXinSimpleTraceCrawlerScheduleTriggerInfo(CrawlerJob crawlerJob){
        metaServiceCommand_15.addOrUpdateScheduleCrawlerTrigger(
                crawlerJob.generateCrawlerKey(),
                crawlerJob.generateCrawlerTriggerKey(),
                WeixinCommonScript.domain,
                CrawlerMetaConstant.ScheduleJobTrigger_Simple,
                "",
                "微信补采"
        );
    }

    @Test
    public  void publicTestTrigger(){
        CrawlerJob crawlerJob = WeixinUIDTraceCrawlerSchedulerJob.crawlerJobScheduler();
        HttpPage httpPage = metaServiceCommand_15.addOrUpdateScheduleCrawlerTrigger(
                crawlerJob.generateCrawlerKey(),
                crawlerJob.generateCrawlerTriggerKey(),
                WeixinUIDTraceCrawlerSchedulerJob.domain,
                CrawlerMetaConstant.ScheduleJobTrigger_Simple,
                "",
                "微信API测试"
        );
    }
}
